package TestExercises01;
//卖飞机票

import java.util.Scanner;

public class test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        int ticket = sc.nextInt();
        System.out.println("请输入月份：");
        int month = sc.nextInt();
        System.out.println("请输入舱位：0 头等舱  1 经济舱");
        int seat = sc.nextInt();
        switch (month) {
            //旺季
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                ticket = getPrice(ticket, seat, 0.9, 0.85);
                break;
            //淡季
            case 11:
            case 12:
            case 1:
            case 2:
            case 3:
            case 4:
                ticket = getPrice(ticket, seat, 0.7, 0.65);
                break;
            default:
                System.out.println("键盘录入的月份不合法！");
        }
        System.out.println(ticket);
    }

    //ctrl+alt+M自动抽取方法
    public static int getPrice(int ticket, int seat, double v0, double v1) {
        if (seat == 0) {
            //头等舱
            ticket = (int) (ticket * 0.9);
        } else if (seat == 1) {
            //经济舱
            ticket = (int) (ticket * 0.85);
        } else {
            System.out.println("没有这个舱位");
        }
        return ticket;
    }
}
